/*
 *Copyright (c) [2019] [name of copyright holder]
 *[Software Name] is licensed under the Mulan PSL v1.
 *You can use this software according to the terms and conditions of the Mulan PSL v1.
 *You may obtain a copy of Mulan PSL v1 at:
 *http://license.coscl.org.cn/MulanPSL
 *THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
 *IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
 *PURPOSE.
 *See the Mulan PSL v1 for more details.
 */

/*!
 * \autor captainpeng
 * \date 2018-9-5
 * \update 2019-1-15
 * \version 1.0
 * \copyright
 */

#ifndef suSeq_hpp
#define suSeq_hpp

#include<lmStd.hpp>

namespace limi{

    template<typename ElementType>
    class suSeqT{
    public:
	using elementType=my::info_type_t<ElementType>;
	using elementRef=my::info_ref_t<ElementType>;
	using elementPtr=my::info_ptr_t<ElementType>;

	const size_t maxblock=my::stdint<16>::UIntMax;
	const size_t maxlen=maxblock/sizeof(elementType);
	const size_t maxindex=256;
	const size_t max=maxlen*maxindex;
    private:
	using bufferType=my::buffer<elementType>;
	using listBufType=my::slist<bufferType>;
	
	listBufTypet mList;
	size_t mSize;
	
    public:
	suSeqT():mBuf(),mSize(0){}

	suSeqT(size_t len):mList(),mSize(0){
	    int count=len;
	    while(count > 0){
		mList.insert(std::move(bufferType(maxlen)));
		count-=maxlen;
	    }
	    mSize=len;
	}
	
	suSeqT(const suSeqT & s):mBuf(s),mSize(s.size()){}

	suSeqT(suSeqT && s):mBuf(std::move(s.mBuf)),mSize(s.size()){
	    s.mSize=0;
	}

	suSeqT & operator=(const suSeqT & s){
	    mBuf=s.mBuf;
	    mSize=s.size();
	}

	suSeqT & operator=(suSeqT && s){
	    mBuf=std::move(s.mBuf);
	    mSize=s.size();
	}

	inline size_t size() const{
	    return mSize;
	}

	inline size_t capacity() const {
	    size_t sum=0;
	    for(int i=0;i < mBuf.size();++i){
		sum+=mBuf[i].size();
	    }
	    return sum;
	}

	void resize(const int len){

	}
    };

    template<typename T>
    using suSeq=suSeqT<my::info_type_t<T>>;
    
}

#endif
